{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Node representations with GraphWave\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "nbsphinx": "hidden",
    "tags": [
     "CloudRunner"
    ]
   },
   "source": [
    "<table><tr><td>Run the latest release of this notebook:</td><td><a href=\"https://mybinder.org/v2/gh/stellargraph/stellargraph/master?urlpath=lab/tree/demos/embeddings/graphwave-embeddings.ipynb\" alt=\"Open In Binder\" target=\"_parent\"><img src=\"https://mybinder.org/badge_logo.svg\"/></a></td><td><a href=\"https://colab.research.google.com/github/stellargraph/stellargraph/blob/master/demos/embeddings/graphwave-embeddings.ipynb\" alt=\"Open In Colab\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\"/></a></td></tr></table>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This demo features the algorithm GraphWave published in \"Learning Structural Node Embeddings via Diffusion Wavelets\" [https://arxiv.org/pdf/1710.10321.pdf]. GraphWave embeds the structural features of a node in a dense embeddings. We will demonstrate the use of GraphWave on a barbell graph demonstrating that structurally equivalent nodes have similar embeddings."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, we load the required libraries."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "nbsphinx": "hidden",
    "tags": [
     "CloudRunner"
    ]
   },
   "outputs": [],
   "source": [
    "# install StellarGraph if running on Google Colab\n",
    "import sys\n",
    "if 'google.colab' in sys.modules:\n",
    "  %pip install -q stellargraph[demos]==1.2.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "nbsphinx": "hidden",
    "tags": [
     "VersionCheck"
    ]
   },
   "outputs": [],
   "source": [
    "# verify that we're using the correct version of StellarGraph for this notebook\n",
    "import stellargraph as sg\n",
    "\n",
    "try:\n",
    "    sg.utils.validate_notebook_version(\"1.2.1\")\n",
    "except AttributeError:\n",
    "    raise ValueError(\n",
    "        f\"This notebook requires StellarGraph version 1.2.1, but a different version {sg.__version__} is installed.  Please see <https://github.com/stellargraph/stellargraph/issues/1172>.\"\n",
    "    ) from None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import networkx as nx\n",
    "from stellargraph.mapper import GraphWaveGenerator\n",
    "from stellargraph import StellarGraph\n",
    "from sklearn.decomposition import PCA\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "from scipy.sparse.linalg import eigs\n",
    "import tensorflow as tf\n",
    "from tensorflow.keras import backend as K"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Graph construction\n",
    "\n",
    "Next, we construct the barbell graph, shown below. It consists of 2 fully connected graphs (at the 'ends' of the graph) connected by a chain of nodes. All nodes in the fully connected ends are structurally equivalent, as are the opposite nodes in the chain. A good structural embedding algorithm should embed equivalent nodes close together in the embedding space."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAb4AAAEuCAYAAADx63eqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd3hUVeLG8e/UTCYQeuhIhyAdUUREREFkcS2gCILYULCtDRXLqthAENAfrK6LrooNLNgRBUVQcEGlG6SX0Ht6MuX+/hhBEALJtDuTeT/P45N9yNw7b1bJO+fcc8+1GIZhICIikiCsZgcQERGJJhWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFBWfiIgkFLvZAUpr/fr9zJ27if3787HZrKSlpXDxxY2pUsVtdjQ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H5wVAJ7ebMTBcXn87Fhw4ZjyrBbxrcMt+/HGmL/fJRl5SFHk+MWlzRv3pzy5WPz/6/N8+Yx76mn2Dx/PhgGvsLCI9+zu1wYhkGD7t3p+sgj1NUjh2KGik9EQjNqKMyYEvJp/O3OxfravDAEir6szEx+nTKF3StWUHDoEK6KFaneujXtb7qJ8rVqmR1P/kI3sItIaKzhuZZmtcXvr6PUOnXo9vjjZseQEtJenSISmuq1IRylVbVm6OcQKQEVn4iEpvsVgW3JQuEuD72vCU8ekVNQ8YlIaBqdDqc1D+0crmTofFF48oicgopPREJ3/QOBpy8EIykZBt4FEbzvTuRoKj4RCd2F/aD12eAs5a4odgfUaQgDdX+bRI9uZxCR8MjPhZsvgLXLobAE27U5kyCtNryxMKz7dIqcikZ8IhIeySnw6veBRSpOF7iKeRKEMynw/c4Xwzu/qvQk6jTiE5HwO7QfPn4N3h4feFyR3QFeD6RWgitvhSuHB57HJ2ICFZ+IRJbXC3nZgRGhw2l2GhEVn4iIJBZd4xMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYSi4hMRkYTy/55pwU167t6MAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m1 = 9\n",
    "m2 = 11\n",
    "gnx = nx.barbell_graph(m1=m1, m2=m2)\n",
    "\n",
    "classes = [0,] * len(gnx.nodes)\n",
    "# number of nodes with a non-zero class (the path, plus the nodes it connects to on either end)\n",
    "nonzero = m2 + 2\n",
    "# count up to the halfway point (rounded up)\n",
    "first = range(1, (nonzero + 1) // 2 + 1)\n",
    "# and down for the rest\n",
    "second = reversed(range(1, nonzero - len(first) + 1))\n",
    "classes[m1 - 1 : (m1 + m2) + 1] = list(first) + list(second)\n",
    "\n",
    "nx.draw(gnx, node_color=classes, cmap=\"jet\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## GraphWave embedding calculation\n",
    "\n",
    "Now, we're ready to calculate the GraphWave embeddings. We need to specify some information about the approximation to use: \n",
    "\n",
    "- an iterable of wavelet `scales` to use. This is a graph and task dependent hyperparameter. Larger scales extract larger scale features and smaller scales extract more local structural features. Experiment with different values. \n",
    "- the `sample_points` at which to sample the characteristic function. This should be of the form `sample_points=np.linspace(0, max_val, number_of_samples)`. The best value depends on the graph.\n",
    "- the `degree` of Chebyshev poly\n",
    "\n",
    "The dimension of the embeddings are `2 * len(scales) * len(sample_points)`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "G = StellarGraph.from_networkx(gnx)\n",
    "sample_points = np.linspace(0, 100, 50).astype(np.float32)\n",
    "degree = 20\n",
    "scales = [5, 10]\n",
    "\n",
    "generator = GraphWaveGenerator(G, scales=scales, degree=degree)\n",
    "\n",
    "embeddings_dataset = generator.flow(\n",
    "    node_ids=G.nodes(), sample_points=sample_points, batch_size=1, repeat=False\n",
    ")\n",
    "\n",
    "embeddings = [x.numpy() for x in embeddings_dataset]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Visualisation\n",
    "\n",
    "The nodes are coloured by their structural role, e.g. in the fully connected sections, first node in the chain, second node in the chain etc. We can see that all nodes of the same colour completely overlap in this visualisation, indicating that structurally equivalent nodes are very close in the embedding space.\n",
    "\n",
    "The plot here doesn't exactly match the one in the paper, which we think is because the details of approximating the wavelet diffusion differ, the paper uses `pygsp` to calculate the Chebyshev coefficient while `StellarGraph` uses `numpy` to calculate the coefficients. Some brief experiments have shown that the `numpy` Chebyshev coefficients are more accurate than the `pygsp` coefficients."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAD4CAYA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IiKOZJsbgakDXGNf9OT1ArgLWAocHcjiqtCTcX0auC8iDgBExN4BrrEvejKuAMZk62OBn/VXMQ6JgTMpInZl67uBSafqLGkWpXcRP+3vwvpgCrCjbLsta6vYJyI6gIPAhAGpru96Mq5yC4Ef9GtFtdHtuCT9JjAtIh4byMKq1JPX6yLgIklPStooac6AVdd3PRnXncDNktqA7wP/qb+KaeivA5+JJK0Dzq2w6/byjYgIScl7jyVNBh4GFkREZ22rtFqQdDNQAH4771qqJakO+EvgUzmX0h8aKE05fZjSWd8/SXpfRLyea1XV+zjwUET8haR/Dzws6ZL++H3hkKihiLg6tU/SHkmTI2JXFgIVT3sljQEeA26PiI39VGq1dgLTyranZm2V+rRJaqB0SrxvYMrrs56MC0lXUwr+346INweotmp0N67RwCXAhmxG8FygRdJ1EVEcsCp7ryevVxuwKSKOAy9JeoFSaGwemBL7pCfjWgjMAYiIH0kaQenL/2o+nebppoHTAizI1hcAj3btIGk48B3gaxGxagBr663NwAxJ07Oa51MaX7ny8d4APB7ZVbZBrNtxSfoN4H8D1w2R+W3oZlwRcTAiJkZEc0Q0U7rWMtgDAnr27/C7lM4ikDSR0vTTiwNZZB/0ZFyvAlcBSLoYGAG090s1eV/JP1MWSvPx64HtwDpgfNZeAO7P1m8GjgNPlS2X5l17YjwfBV6gdM3k9qxtCaVfLmT/aB8BWoEfA7+Sd801Gtc6YE/Z69OSd821GFeXvhsYAnc39fD1EqWptG3AM8D8vGuu0bhmAk9SuvPpKWB2f9Xir+UwM7MkTzeZmVmSQ8LMzJIcEmZmluSQMDOzJIeEmZklOSTMzCzJIWFmZkn/H+3o0nT+MabZAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "trans_emb = PCA(n_components=2).fit_transform(np.vstack(embeddings))\n",
    "\n",
    "plt.scatter(\n",
    "    trans_emb[:, 0], trans_emb[:, 1], c=classes, cmap=\"jet\", alpha=0.7,\n",
    ")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "nbsphinx": "hidden",
    "tags": [
     "CloudRunner"
    ]
   },
   "source": [
    "<table><tr><td>Run the latest release of this notebook:</td><td><a href=\"https://mybinder.org/v2/gh/stellargraph/stellargraph/master?urlpath=lab/tree/demos/embeddings/graphwave-embeddings.ipynb\" alt=\"Open In Binder\" target=\"_parent\"><img src=\"https://mybinder.org/badge_logo.svg\"/></a></td><td><a href=\"https://colab.research.google.com/github/stellargraph/stellargraph/blob/master/demos/embeddings/graphwave-embeddings.ipynb\" alt=\"Open In Colab\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\"/></a></td></tr></table>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
